﻿using System;
using System.ComponentModel;
using Notoric.Commanding.CommandBase;

namespace Notoric.View.Music.CWNotation
{
    /// <summary>
    /// The bridge between this assembly and GUI for accessing the application state.
    /// </summary>
    public class ApplicationBridge
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationBridge"/> class.
        /// </summary>
        /// <param name="currentState">Current application state</param>
        private ApplicationBridge(IApplicationState currentState)
        {
            State = currentState;
        }

        /// <summary>
        /// Creates the instance.
        /// </summary>
        /// <param name="currentState">Current application state</param>
        public static void CreateInstance(IApplicationState currentState)
        {
            ApplicationBridge.Current = new ApplicationBridge(currentState);
        }

        /// <summary>
        /// Gets the current instance.
        /// </summary>
        /// <value>
        /// The current instance.
        /// </value>
        public static ApplicationBridge Current
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets or sets the state.
        /// </summary>
        /// <value>The state.</value>
        public IApplicationState State
        {
            get;
            private set;
        }
    }

    /// <summary>
    /// Interface of the current application state.
    /// </summary>
    public interface IApplicationState : INotifyPropertyChanged
    {
        /// <summary>
        /// Gets or sets the command that should be executed when the user finishes the mouse action.
        /// </summary>
        /// <value>
        /// <para>
        /// Type: <see cref="CommandBase"/>
        /// </para>
        /// <para>
        /// The command that should be executed when the user finishes the mouse action.<br/>
        /// If this value is <see langword="null"/> the action is left to the control that
        /// receives the input.
        /// </para>
        /// </value>
        CommandBase Command
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the application part that is currently the target of the mouse action.
        /// </summary>
        /// <value>
        /// <para>
        /// Type: <see cref="Type"/>
        /// </para>
        /// <para>
        /// The application part that is currently meant to be a target of a user action.
        /// This part alone should receive mouse input, all the other parts
        /// should disable them selves or refuse the mouse input.<br/>
        /// If this value is <see langword="null"/> the whole application area is mouse enabled.
        /// </para>
        /// <para>
        /// This property is used for example when the user wants to insert a new
        /// section to a page. He has to first draw the area where he wants
        /// to put the new section. The only part that should now receive
        /// the mouse input is the page.
        /// </para>
        /// </value>
        Type MouseTarget
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the status bar message.
        /// </summary>
        /// <value>
        /// <para>
        /// Type: <see cref="string"/>
        /// </para>
        /// <para>
        /// An optional message for the user displayed in the application status bar.
        /// </para>
        /// </value>
        string StatusBarMessage
        {
            get;
            set;
        }
    }
}
